<?php
/**
 * Created by PhpStorm.
 * User: 10037
 * Date: 2022/6/1
 * Time: 20:00
 */

namespace app\admin\model;


use think\Model;

class Foods extends Model
{
    protected $pk="id";

    public function busine(){
        return $this->belongsTo(Business::class,'busId','id');
    }

    public function foodClass(){
        return $this->belongsTo(Foodclass::class,'foodClassId','id');
    }

    public function addFoods($data){
        return $this->insertGetId($data);
    }

    public function selectFoods($page){
       return $this->where('delete','=',0)->with(['busine','foodClass'])->page($page,10)->select();
    }

    public function selectIdFoods($id){
        return $this->find($id);
    }

    public function deleteFoods($id){
       $result= $this->find($id);
       $result['delete']=1;
       $result->save();
    }
}